#[derive(Debug, Clone, PartialEq)]
pub enum Error {
	Eof,
	Io(String),
	Msg(&'static str),
	Unexpect(String),
	Expect(String, Option<String>),
	Integer(core::num::ParseIntError),
	Real(core::num::ParseFloatError),
}
impl core::error::Error for Error {}
impl core::fmt::Display for Error {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			Error::Msg(s) => s.fmt(f),
			Error::Eof => f.write_str("Eof"),
			Error::Io(s) => s.fmt(f),
			Error::Unexpect(s) => s.fmt(f),
			Error::Expect(e, Some(fd)) => f.write_fmt(format_args!("expect {},found {}", e, fd)),
			Error::Expect(e, None) => f.write_fmt(format_args!("expect {}", e)),
			Error::Integer(e) => e.fmt(f),
			Error::Real(e) => e.fmt(f),
		}
	}
}
impl From<&'static str> for Error {
	fn from(value: &'static str) -> Self {
		Self::Msg(value)
	}
}
impl Error {
	pub fn unexpect(e: impl std::fmt::Debug) -> Self {
		Self::Unexpect(format!("{:?}", e))
	}
}
